<?php

class Core_Agent_Component_Customer_View_Showroom_Index extends Core_Agent_Share_View_Grid {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('index/index'), $this->__('share.button.back'));
        parent::buildToolbar($toolbar);
        $group = $toolbar->createGroup();
        $group->addLink($this->getUrl(array('poiid' => $this->getPoi()->getId()), 'create'), $this->__('share.button.create'));
    }

    protected function buildGrid($grid) {            	
        $grid->setId('grid')
                ->setPrimaryKey('id')
                ->setAllowCheck(FALSE);
        $grid->addLabelColumn($this->__('share.label.name'), 'name', '{name}');
        $grid->addLabelColumn($this->__('share.label.click_count'), 'click_count', '{click_count}')
                ->setWidth(80)
                ->setAlign('center');         
        $grid->addDatetimeColumn($this->__('share.label.created_time'), 'created_time', '{created_time}')
                ->setWidth(100);        
        $grid->addLabelColumn($this->__('share.label.creator'), 'creator', '{creator}')
                ->setWidth(60);               
        $grid->addLabelColumn($this->__('share.label.status'), 'status', '{{lang "status.publication.{status}"}}')
                ->setWidth(80)
                ->setAlign('center');
        $grid->addLinkColumn('', 'sd', '/customer/showroom/sd/id/{id}', $this->__('customer.label.sd'), '_blank')
                ->setWidth(40)
                ->setAlign('center');
        $grid->addLinkColumn('', 'hd', '/customer/showroom/hd/id/{id}', $this->__('customer.label.hd'), '_blank')
                ->setWidth(40)
                ->setAlign('center');                                               
        if($this->getIdentity()->isAllowAction('customer_showroom_certificate_read')){
	        $grid->addLinkColumn('', 'certificates', $this->getUrl(array('id' => '{id}'), 'certificate-index'), $this->__('customer.label.certificate'))
	                ->setWidth(60)
	                ->setAlign('center');
        }
        if($this->getIdentity()->isAllowAction('customer_showroom_edit')){
	        $grid->addLinkColumn('', 'edit', $this->getUrl(array('id' => '{id}'), 'edit'), $this->__('share.button.edit'))
	                ->setWidth(40)
	                ->setAlign('center');
        }                             
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        parent::buildPagination($pagination);
        $pagination->setUrlFormat($this->getPaginationUrl())
                ->setRecordCount($this->getRecords());
    }

}